home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u136.dms / in.adf / nopalreset / NoPalReset.S < prev    next >
Encoding:
Text File  |  1978-08-30  |  1.7 KB  |  54 lines

  1.  
  2. * NoPalReset by Declan Mc Ardle.
  3. * Detects if Amiga is in NTSC or PAL mode, resets if in NTSC mode.
  4.  
  5.  INCLUDE "includes:exec/types.i"
  6.  INCLUDE "includes:graphics/gfxbase.i"
  7.  INCLUDE "includes:exec/exec_lib.i"
  8.  
  9.  section NoPalReset,code
  10.  
  11. execbase equ 4
  12.  
  13.  jsr opengfx                   ;Try and open graphics library.
  14.  tst d0                        ;Is it 0 ?
  15.  beq exit                      ;If so exit, else
  16.  move.l GfxBase,a1             ;Put GfxBase in a1.
  17.  move.w gb_DisplayFlags(a1),d0 ;Put gb_DisplayFlags in d0.
  18.  cmp.w #1,d0                   ;Compare it with 1 (NTSC).
  19.  beq reboot                    ;If it's equal, reset.
  20.  
  21. exit:
  22.  jsr closegfx                  ;Close graphics library.
  23.  clr.l d0                      ;Clear d0.
  24.  rts                           ;Go back to CLI.
  25.  
  26. reboot:
  27.  even                          ;IMPORTANT: Must be longword aligned.
  28.  move.l execbase,a6            ;Get a pointer to ExecBase.
  29.  lea.l MagicResetCode(pc),a5   ;Location of code to trap to
  30.  jsr _LVOSupervisor(a6)        ;start code (must use jsr).
  31.  
  32. MagicResetCode: 
  33.  lea.l 2,a0         ;Point to jmp instruction at start of rom.
  34.  reset              ;All ram goes away now!
  35.  jmp (a0)           ;Rely on prefetch to execute this instruction.
  36.  
  37. opengfx:
  38.  move.l execbase,a6            ;Put 4 in a6.
  39.  lea gfxlib,a1                 ;Put GfxBase in a1.
  40.  move.l #0,d0                  ;Any version.
  41.  jsr _LVOOpenLibrary(a6)       ;OpenLibary()
  42.  move.l d0,GfxBase             ;Put address in GfxBase.
  43.  rts                           ;Return.
  44.  
  45. closegfx:
  46.  move.l GfxBase,a1             ;Move address in GfxBase to a1
  47.  jsr _LVOCloseLibrary(a6)      ;and CloseLibrary()
  48.  rts                           ;Return.
  49.  
  50. gfxlib: dc.b 'graphics.library',0
  51. myname: dc.b 'NoPalReset by Declan Mc Ardle.',0
  52.  
  53.  end
  54.